<%@ page language="java" import="java.util.*"
	contentType="text/html; charset=utf-8"%>
<!doctype html>
<html>
<head lang="en">
<title>幼儿监护系统</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="icon" type="image/png" href="assets/i/favicon.png">
<link rel="apple-touch-icon-precomposed"
	href="assets/i/app-icon72x72@2x.png">
<link rel="stylesheet" href="/yejhxt/assets/css/amazeui.min.css" />
<link rel="stylesheet" href="/yejhxt/assets/css/admin.css">
<link rel="stylesheet" href="/yejhxt/assets/css/custom.css" />
<link rel="stylesheet"
	href="/yejhxt/assets/css/amazeui.datetimepicker.css" />



<script src="/yejhxt/assets/js/jquery.min.js"></script>
<script src="/yejhxt/assets/js/js.KinerCode.js"></script>

<script src="/yejhxt/assets/js/custom.js"></script>
<script src="/yejhxt/assets/js/amazeui.min.js"></script>
<script src="/yejhxt/assets/js/amazeui.datetimepicker.js"></script>

<style type="text/css">
.doing {
	cursor: pointer;
	background-color: #FFFFFF;
}
.danger {
	cursor: pointer;
	background-color: #FFFFFF;
}
</style>

</head>

<body>
	<%@ include file="../commoms/sysHead.txt"%>

	<div class="admin-content">
		<div class="admin-content-body">
			<div class="am-cf am-padding am-padding-bottom-0">
				<div class="am-fl am-cf">
					<strong class="am-text-primary am-text-lg">表格</strong> / <small>Table</small>
				</div>
			</div>

			<hr>


			<div class="am-g">
				<div class="am-u-sm-12">
					<form class="am-form">
						<table class="am-table am-table-striped am-table-hover table-main">
							<thead>
								<tr>

									<th class="table-id">ID</th>
									<th class="table-title">用户</th>
									<th class="table-author am-hide-sm-only">持有人</th>
									<th class="table-author am-hide-sm-only">设备ID</th>
									<th class="table-date am-hide-sm-only">发生时间</th>
									<th class="table-set">经度</th>
									<th class="table-set">纬度</th>
									<th class="table-set">email</th>
									<th class="table-author am-hide-sm-only">联系电话</th>
									<th class="table-set">QQ</th>
									<th class="table-set">家庭住址</th>
									<th class="table-set">状态</th>
								</tr>
							</thead>

							<tbody id="pagecontainer">

							</tbody>
						</table>

						<hr />
					</form>
				</div>

			</div>
		</div>

	</div>


	</div>
	<a href="#"
		class="am-icon-btn am-icon-th-list am-show-sm-only admin-menu"
		data-am-offcanvas="{target: '#admin-offcanvas'}"></a>


	<script type="text/javascript">
		var currentpage = 1;
		var pages = 1;
		var $pagecontainer = $('#pagecontainer');
		var ldata = null;
		var alldata = null;
		var nums = 0;
		getdiffstatuscontent("/yejhxt/api/sysuser/getsosmessage.do", {},
				$pagecontainer);

		function getdiffstatuscontent(url, parameters, $pagecontainer) {

			myAjax(url, parameters, function(data) {
				alldata = data.result;
 
				drawDiffStatusContent($pagecontainer, alldata);

			});

		}
		function drawDiffStatusContent($pagecontainer, data) {

			$.each(data, function(i, item) {
				var temp = '',claz='';
				switch (item.status) {
				case 1:
					temp='紧急';
					claz='danger';
					break ;
				case 2:
					temp='处理中';
					claz='doing';
					break ;
					default:
						temp='安全';
				}
				$pagecontainer.append(' <tr  class='+claz+' id='+claz+(i)+'><td>' + (i + 1) + '</td><td>'
						+ item.role.realname + '</td><td>' + item.device.holder
						+ '</td><td>' + item.device.devicecode

						+ '</td><td>' + item.happendtime + '</td><td>'
						+ item.longtitude + '</td><td>' + item.latitude
						+ '</td> <td>' + item.role.email + '</td><td>'
						+ item.role.phone + '</td><td>' + item.role.qq
						+ '</td><td>' + item.role.address + '</td><td>'
						+ temp + '</td></tr>');

			});

		}
		
		$pagecontainer.on("click",".danger",function(e){
			 $('#'+e.currentTarget.id).popover({
				    content: '打电话报警或者通知家长'
				  })
		});
		$pagecontainer.on("click",".doing",function(e){
			var pid = e.currentTarget.id;
			var index = pid.replace('doing', "");
			
			 myConfirm("警告", "孩子已经安全？是否更改状态为安全？", function(e){
				 
				 myAjax("/yejhxt/api/sysuser/changesos.do", {"sosiid":alldata[index].sosiid}, function(e){ myAlert("提示", "操作成功",function(e){
					 
					 window.location.href="/yejhxt/sysmanager/sos.jsp";
				 })});
				 
			 }, function(e){}).modal("open"); ;
		});
		
	</script>

</body>
</html>
